//
//  ZWHTeaViewModel.swift
//  约麻
//
//  Created by Syrena on 2017/7/19.
//  Copyright © 2017年 Sweet. All rights reserved.
//

import UIKit

class ZWHTeaViewModel {
    var tea:BMKPoiInfo
    var distance:Int
    
    init(tea:BMKPoiInfo) {
        self.tea = tea
        /*BMKMapPoint point1 = BMKMapPointForCoordinate(CLLocationCoordinate2DMake(39.915,116.404));
         BMKMapPoint point2 = BMKMapPointForCoordinate(CLLocationCoordinate2DMake(38.915,115.404));
         CLLocationDistance distance = BMKMetersBetweenMapPoints(point1,point2);
         */
        let point1 = CLLocation(latitude: tea.pt.latitude, longitude: tea.pt.longitude)
        let lat = UserDefaults.standard.double(forKey: "userlat")
        let long = UserDefaults.standard.double(forKey: "userlong")
        let point2 = CLLocation(latitude: lat, longitude: long)
        let dist = point2.distance(from: point1)
        self.distance = Int(dist)
    }
    
}
